<?php

namespace App\Request;

use Hyperf\Validation\Request\FormRequest;

class ArticleRequest extends FormRequest
{
    public function rules(): array
    {
        $rules = [
            'title' => 'required|string|max:255',
            'content' => 'required|string',
            'cover_image' => 'required|string',
            'tags' => 'sometimes|array',
            'content_type' => 'sometimes|in:markdown,html',
            'status' => 'sometimes|in:draft,published,review,archived'
        ];
        return $rules;
    }

    public function messages(): array
    {
        return [
            'title.required' => '文章标题不能为空',
            'title.max' => '文章标题不超过255个字符',
            'content.required' => '文章内容不能为空',
            'cover_image.required' => '文章封面不能为空',
            'tags.array' => '标签必须是数组',
            'content_type.in' => '类型必须是markdown或html',
            'status.in' => '状态值不正确'
        ];
    }

    public function attributes(): array
    {
        return [
            'title' => '文章标题',
            'content' => '文章内容',
            'cover_image' => '封面图',
            'tags' => '标签',
            'content_type' => '内容类型',
            'status' => '状态'
        ];
    }
}